﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using V = Science.Mathematics.VectorCalculus;

namespace VectorCalculus5Ed.Chapter3.Section1
{
    public class Example03
    {
        public Example03()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
        public void Compute()
        {
            V.Function.ToLastType<double[], double> f
                = new V.Function.ToLastType<double[], double>(func);
            double[] at = { 1.0, 0.5, 2.0 };

            V.IteratedPartialDerivative ddf
                = new V.IteratedPartialDerivative(f, at);

            ddf.WithRespectToFirst = 2;
            ddf.WithRespectToSecond = 0;
            ddf.Compute();
            result += ddf.Result.ToString() + "\r\n";

            result += (-Math.Sin(at[0])).ToString() + "\r\n";
        }
        private double func(double[] x)
        {
            return Math.Exp(x[0]*x[1]) + x[2] * Math.Cos(x[0]);
        }
    }
}
/* 
-0.841470984242653
-0.841470984807897
*/
